local weifeng = fk.CreateSkill {
  name = "lingling__weifeng",
}

Fk:loadTranslationTable{
  ["lingling__weifeng"] = "威凤",
  [":lingling__weifeng"] = "出牌阶段限一次，你可以失去一个技能，然后选择你手牌中一张基本牌或普通锦囊牌，获得一张与之同名的牌。",

  ["#lingling__weifeng"] = "威凤：失去一个技能，然后获得手牌中一张基本牌或普通锦囊牌的同名牌",
  ["#lingling__weifeng-ask"] = "威凤：选择一张手牌，获得一张同名牌",
}

weifeng:addEffect("active", {
  anim_type = "special",
  prompt = "#lingling__weifeng",
  target_filter = Util.FalseFunc,
  card_filter = Util.FalseFunc,
  interaction = function(self, player)
    return UI.ComboBox { choices = player:getSkillNameList() }
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(weifeng.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:handleAddLoseSkills(player, "-" .. self.interaction.data)
    if player.dead then return end
    local cards = table.filter(player:getCardIds("h"), function (id)
      local c = Fk:getCardById(id)
      return c.type == Card.TypeBasic or c:isCommonTrick()
    end)
    if #cards == 0 then return end
    local card = room:askToCards(player, {
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = weifeng.name,
      pattern = tostring(Exppattern{ id = cards }),
      prompt = "#lingling__weifeng-ask",
      cancelable = false,
    })
    card = Fk:getCardById(card[1])
    local c = room:getCardsFromPileByRule(card.name, 1, "allPiles")
    if #c == 0 then
      c = room:printCard(card.name, card.suit, card.number)
    end
    room:obtainCard(player, c, false, fk.ReasonJustMove, player, weifeng.name)
  end,
})

return weifeng
